<template>
  <div id="sign" v-if="show">
    <div class="bg"></div>
    <div class="modal">
      <div class="modalPrompt">转发贴子</div>
      <textarea
        name=""
        id=""
        cols="30"
        rows="10"
        v-model="forwardCtn"
        maxlength="140"
      ></textarea>
      <div class="sign-btn" @click="submit">转发</div>
      <div class="clear-btn" @click="showModal">
        <img src="../assets/imgs/cha.png" alt="" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    listId: {
      type: Number,
    },
  },
  data() {
    return {
      btnShow: true,
      show: false,
      modalList: [],
      forwardCtn: "",
      id: 0,
      list: [],
    };
  },
  watch: {
    listId: {
      handler(newVal, oldVal) {
        this.id = newVal;
        this.$post(`/laiwen/article/frontend/info/${this.id}`).then((res) => {
          this.list = res.article;
        });
      },
    },
  },
  created() {},
  mounted() {
    this.getRem(1920, 100);
  },
  methods: {
    showModal() {
      this.show = !this.show;
    },
    init(url, listName, page) {
      this.loading = true;
      this.$fetch(`${url}?page=${page}&limit=3`, {}).then((res) => {
        this.loading = false;
        this.totalPage = res.totalPages * 1;
        this.count = res.count * 1;
        this.res = res;
        this.$set(res, "articleShow", true);
        this.artList = res[listName];
        //处理图片为空的样式
        for (let i of this.artList.keys()) {
          this.$set(this.artList[i], "show", true);
          if (this.artList[i].articlePicture == "") {
            this.$set(this.artList[i], "show", false);
          }
          //处理图片数组
          let picArray = [];
          picArray = this.artList[i].articlePicture.split(",").filter((e) => e);
          this.$set(this.artList[i], "pic", picArray);
          //处理星星数组
          let len = this.artList[i].award+1;
          let stars = [];
          stars.length = len;
          this.$set(this.artList[i], "stars", stars);
          //处理收藏模态窗
          this.$set(this.artList[i], "showCollect", false);
          //处理talk为空的情况
          this.$set(this.artList[i], "showTalk", true);
          if (this.artList[i].talk == null) {
            this.$set(this.artList[i], "showTalk", false);
          }
        }
        //list为空的样式处理
        if (this.artList.length == 0) {
          this.$set(res, "articleShow", false);
        }
        console.log(this.artList);
      });
    },
    //转发
    async submit() {
      this.$set(this.list, "forwardContent", this.forwardCtn);
      const res = await this.$post(
        `/laiwen/article/frontend/forward`,
        this.list
      );
      this.$message({
        type: "success",
        message: "亲亲转发成功了哦",
      });
      this.showModal();
      let e = this.$store.state.pageState;
      let size = this.$store.state.size;
      this.$emit('countAdd');
      this.$parent.forwardPage({size,e});
    },
  },
};
</script>

<style scoped>
#sign {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  position: fixed;
  left: 0;
  top: 0;
  justify-content: center;
  z-index: 3333;
}
img {
  width: 100%;
  height: 100%;
  flex-shrink: 0;
}
.modal .modalFavor {
  width: 1.6rem;
  height: 0.28rem;
  font-size: 0.2rem;
  font-family: PingFang SC;
  font-weight: bold;
  line-height: 0.28rem;
  color: rgba(9, 9, 9, 1);
  opacity: 1;
  margin-bottom: 0.24rem;
}
.modal textarea {
  width: 4.64rem;
  height: 0.76rem;
  background: rgba(247, 247, 247, 1);
  opacity: 1;
  outline: none;
  border: none;
  border-radius: 0.05rem;
  font-size: 0.14rem;
  font-family: PingFang SC;
  font-weight: 400;
  box-sizing: border-box;
  padding: 0.12rem;
  resize: none;
  color: rgba(40, 40, 40, 1);
}
.modal .modalTag {
  width: 2.15rem;
  height: 0.46rem;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0rem 0rem 0.05rem rgba(0, 0, 0, 0.16);
  border-radius: 0.44rem;
  margin-bottom: 0.16rem;
  font-size: 0.16rem;
  font-family: PingFang SC;
  font-weight: 400;
  color: rgba(152, 152, 152, 1);
  opacity: 1;
  align-self: flex-start;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.InterSelected {
  background: #fcec5b !important;
  color: #090909 !important;
}
.modal .modalTag:nth-of-type(even) {
  margin-left: 1.52rem;
}
.modal .modalTag:nth-of-type(odd) {
  margin-left: 0.69rem;
}
.modal .modalTag:nth-of-type(7) {
  margin-bottom: 0rem;
}
.bg {
  width: 100%;
  height: 100%;
  opacity: 0.25;
  background: black;
  position: absolute;
  z-index: -1;
}
.selected {
  background: #ffd52f !important;
  color: #ffffff !important;
  border: 0.01rem solid transparent !important;
}

.modal {
  width: 5rem;
  min-height: 2.68rem;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  display: flex;
  align-items: center;
  position: relative;
  flex-direction: column;
  z-index: 9999;
  background: white;
  padding: 0.32rem;
  box-sizing: border-box;
}
.modal-btns {
  width: 4.36rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}
.modalTitle {
  width: 100%;
  display: flex;
  font-size: 0.18rem;
  font-family: PingFang SC;
  font-weight: 400;
  color: rgba(9, 9, 9, 1);
  opacity: 1;
  position: relative;
  justify-content: space-between;
}
.interestBtn {
  margin-top: 0.32rem !important;
}
.quesIcon {
  width: 0.3rem;
  height: 0.3rem;
  opacity: 1;
  overflow: hidden;
  border-radius: 50%;
  position: absolute;
  right: 1.18rem;
}
.grade {
  width: 4.36rem;
  height: 0.24rem;
  background: rgba(238, 238, 238, 1);
  opacity: 1;
  border-radius: 0.12rem;
  margin: 0.28rem 0rem;
}
.question {
  width: 4.17rem;
  font-size: 0.2rem;
  font-family: PingFang SC;
  font-weight: bold;
  color: rgba(9, 9, 9, 1);
  opacity: 1;
  margin-bottom: 0.4rem;
}
.answer {
  display: flex;
  font-size: 0.19rem;
  font-family: PingFang SC;
  font-weight: 400;
  color: rgba(9, 9, 9, 1);
  opacity: 1;
  align-self: flex-start;
  max-width: 4.17rem;
  margin-bottom: 0.24rem;
}
label {
  font-size: 0.19rem;
  font-family: PingFang SC;
  font-weight: 400;
  color: rgba(9, 9, 9, 1);
  opacity: 1;
  margin-left: 0.16rem;
}
.finish {
  background: #999999 !important;
  color: #ffffff !important;
}

image {
  width: 100%;
  display: block;
  height: 100%;
}
.modal-text {
  height: 0.2rem;
  font-size: 0.14rem;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 0.2rem;
  color: rgba(9, 9, 9, 1);
  opacity: 1;
}
.modal-btn {
  width: 0.88rem;
  height: 0.78rem;
  background: rgba(238, 238, 238, 1);
  opacity: 1;
  border-radius: 0.05rem;
  margin-top: 0.08rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: rgba(153, 153, 153, 1);
  cursor: pointer;
}
.modal-btn .gift-icon {
  width: 0.31rem;
  height: 0.31rem;
  margin-top: 0.13rem;
}
.gift-text {
  margin-top: 0.07rem;
  height: 0.2rem;
  font-size: 0.14rem;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 0.2rem;
  opacity: 1;
}
.sign-btn {
  width: 3.3rem;
  height: 0.48rem;
  background: rgba(255, 213, 47, 1);
  opacity: 1;
  border-radius: 0.4rem;
  font-size: 0.22rem;
  font-family: PingFang SC;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 400;
  color: rgba(255, 255, 255, 1);
  opacity: 1;
  cursor: pointer;
  margin-top: 0.39rem;
}
.clear-btn {
  width: 0.24rem;
  height: 0.24rem;
  border-radius: 50%;
  opacity: 1;
  position: absolute;
  right: -0.28rem;
  top: -0.28rem;
  cursor: pointer;
}
/* 表示总长度背景色 */
progress::-webkit-progress-bar {
  background-color: #eeeeee;
  border-radius: 0.12rem;
}
progress::-webkit-progress-value {
  background: #ffd52f;
  border-radius: 0.2rem;
}

input[type="radio"] {
  width: 0.2rem;
  height: 0.2rem;
  position: relative;
  appearance: none;
  vertical-align: middle;
  outline: none !important;
}
input[type="radio"]::before {
  position: absolute;
  content: "";
  top: 50%;
  left: 0;
  margin-top: -0.1rem;
  width: 100%;
  height: 100%;
  width: 0.2rem;
  height: 0.2rem;
  background: rgba(255, 255, 255, 1);
  border: 0.01rem solid rgba(208, 208, 208, 1);
  opacity: 1;
  border-radius: 0.03rem;
}
input[type="radio"]:checked::before {
  position: absolute;
  content: "\2713";
  font-size: 0.2rem;
  font-weight: bold;
  text-align: center;
  color: white;
  background: #ffd52f;
  border: 0.01rem solid transparent;
  line-height: 0.2rem;
}
.modalIcon {
  width: 1.59rem;
  height: 1.59rem;
  background: rgba(255, 227, 0, 1);
  opacity: 1;
  margin-top: 0.76rem;
  border-radius: 50%;
  overflow: hidden;
}
.modalPrompt {
  height: 0.37rem;
  font-family: PingFang SC;
  font-weight: bold;
  color: rgba(9, 9, 9, 1);
  opacity: 1;
  align-self: flex-start;
  font-size: 0.18rem;
  font-weight: 400;
  opacity: 1;
}
.modalText {
  width: 1.8rem;
  height: 0.28rem;
  font-size: 0.2rem;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 0.28rem;
  color: rgba(153, 153, 153, 1);
  opacity: 1;
}
</style>
